<template>
  <div id="orderdetails">
    <el-button type="text" @click="back">返回</el-button><br>
    订单管理：<span v-for="item in orderidList" :key="item.id">{{ item.id }}</span><br>
    下单时间：<span v-for="item in orderidList" :key="item.orderTime">{{ item.orderTime }}</span><br>
    订单状态：<span v-for="item in orderidList" :key="item.status">{{ item.status }}</span><br>
    员工编号：<span v-for="item in orderidList" :key="item.customerId">{{ item.customerId }}</span><br>
    顾客：<span>{{ orderidList.data.customer.realname }}</span><br>
    顾客手机号：<span>{{ orderidList.data.customer.telephone }}</span><br>
  </div>
</template>
<script>

export default {
  data() {
    return {
      orderidList: []
    }
  },
  computed: {
    orderidLists() {
      // var self = this;
      this.orderidList.map((item) => {
        item.orderTime = new Date(item.orderTime).toLocaleDateString()
      })
      return this.orderidList
    }
  },
  created() {
    this.findOrderId()
  },
  methods: {
    // 给返回按钮绑定事件
    back() {
      this.$router.back()
    },

    // 根据订单ID展示定单的信息
    findOrderId() {
      var id = this.$route.query.id
      console.log(id)
      this.$axios.get('/order/findById', { params: { id }}).then(response => {
        // console.log(response.data);
        this.orderidList = response.data
        console.log(this.orderidList.data.customer)
      })
    }
  }
}
</script>
<style lang="scss" scoped>
#orderdetails{
  padding: 20px;
  line-height: 35px;
}
</style>
